package yy.robot.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import yy.robot.domain.RobotRunning;
import yy.robot.repository.RobotRunningRepository;

/**
 * Created by BaiJiFeiLong@gmail.com at 2018/5/7 11:19
 */
@Service
public class RobotRunningService {

    @Autowired
    private RobotRunningRepository robotRunningRepository;

    public Page<RobotRunning> findAll(Pageable pageable) {
        return robotRunningRepository.findAll(pageable);
    }

    public RobotRunning findById(long id) {
        return robotRunningRepository.findById(id).get();
    }

    public RobotRunning create(RobotRunning robotRunning) {
        robotRunningRepository.save(robotRunning);
        return robotRunning;
    }

    public RobotRunning update(RobotRunning robotRunning) {
        robotRunningRepository.save(robotRunning);
        return robotRunning;
    }

    public void destroy(long id) {
        robotRunningRepository.deleteById(id);
    }
}
